package main;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;
import java.util.Set;

public class PlanesProp {
	private static Properties planeProp;

	/**
	 * Read constants and parameters from default.properties file and overwite
	 * them with current.properties if needed
	 * 
	 * @throws IOException
	 */
	public static void load() throws IOException {
		// create and load default properties
		planeProp = new Properties();
		try (FileInputStream in = new FileInputStream("planesInfos.properties")) {
			planeProp.load(in);
			in.close();
		}
	}
	
	/**
	 * Return the value of a propertie
	 * 
	 * @param key
	 *            : propertie name
	 * @return String: propertie value
	 */
	public static String getModel(String key) {
		String tmp=planeProp.getProperty(key);
		String [] infos = null;
		String result=null;
		if (tmp != null ) {
			infos=tmp.split(";");
			result=infos[1];
		}
		return result;
	}

	public static String getScript(String key) {
		String tmp=planeProp.getProperty(key);
		String [] infos = null;
		String result=null;
		if (tmp != null ) {
			infos=tmp.split(";");
			result=infos[0];
		}
		return result;
	}

	/**
	 * 
	 * @return the keys of the propertie
	 */
	
		public static String[] getPlaneskeys() {

			Set<Object> keys = planeProp.keySet();
			String[] result=new String[planeProp.size()];
			int i=0;
			for (Object planeName : keys) {
				result[i++]=planeName.toString();
			}
			return result;
		}
	

}
